import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // 登录模块路由(懒加载)
  { path: '/login', name: 'login', component: () => import('../views/login.vue') },
  // 首页路由
  {
    path: '/',
    component: () => import('../views/layout/index.vue'),
    children: [
      { path: '', component: () => import('../views/home/index.vue') },
      { path: '/qa', component: () => import('../views/qa/index.vue') },
      { path: '/video', component: () => import('../views/video/index.vue') },
      { path: '/my', component: () => import('../views/my/index.vue') }
    ]
  },
  // 搜索路由
  { path: '/search', name: 'search', component: () => import('../views/search/index.vue') },
  // 文章详情路由(设计为动态路由(含动态参数))
  { path: '/article/:articleId', name: 'article', component: () => import('../views/article/index.vue'), props: true },
  // 编辑用户资料路由
  { path: '/user/profile', name: 'user-profile', component: () => import('../views/user-profile/index.vue') }

]

const router = new VueRouter({
  routes
})

export default router
